class Solution
{
public:
    bool isAnagram(string s, string t)
    {
        unordered_map<char, int> ms, mt;
        for (auto e : s)
            ms[e]++;
        for (auto e : t)
            mt[e]++;
        if (ms.size() != mt.size())
            return false;
        for (const auto &[ch, cnt] : ms)
            if (mt[ch] != cnt)
                return false;
        return true;
    }
};